#!usr/bin/python
# -*- coding:utf8 -*-
import random

"""
	          香蕉
		猴子		箱子
		a      b     c
"""

class Monkey(object):
	
	def __init__(self, monkey_loc, banna_loc, box_loc):
		self.monkey_loc = monkey_loc
		self.banna_loc = banna_loc
		self.box_loc = box_loc
		
		self.step = 0	# 记录操作步数
		self.on_box_flag = False  # 记录猴子爬上了箱子上
		
	def goto(self, x):
		self.monkey_loc = x
		self.step += 1
		print('step=', self.step, 猴子从', self.monkey_loc, '走到', x)
	
	def push_box(self, x):
		
		if self.monkey_loc == self.box_loc:
			self.step += 1
			print('step=', self.step, '猴子把箱子从', self.box_loc, '推到', x)
			self.box_loc = x
			self.money_loc = self.box_loc
		else:
			print('猴子不在箱子旁边，无法推！！！')
		
	def climb_on_box(self):
		if self.monkey_loc == self.box_loc:
			self.step += 1
			self.flag = 1
			print('step=', self.step, '猴子爬上箱子')
		else:
			print('猴子不在箱子旁边，无法爬上！！！')
	
	def grap(self):
		
		if self.box_loc == self.banna_loc && self.on_box_flag:
			self.step += 1
			print('step=', self.step, '猴子摘到香蕉')
			
		
def main():
	print('请输入猴子, 香蕉, 箱子的位置')
	monkey_loc = input('monkey=')
	banna_loc = input('banna=')
	box_loc = input('box=')
	
	monkey = Monkey(monkey_loc, banna_loc, box_loc)
	
	while True:
		x = random.randomint(100)
		monkey.goto(x)
		
		x = random.randomint(100)
		monkey.push_box(x)
		
		monkey.climb_on_box()
		monkey.grap()

	
if __name__ == '__main__':
	main()